﻿using EF_基础1.Datas;
using EF_基础1.Models;

using (PigeonDbContext ctx = new PigeonDbContext())
{
    List<Pigeon> pigeons = new List<Pigeon>()
    {
        new Pigeon()
        {
            Name="坦克",
            Age=3,
            FeatherColor="雨点"           
        },
        new Pigeon()
        {
            Name="白雪公主",
            Age=3,
            FeatherColor="白色"
        }
    };

    PigeonOwner pigeonOwner = new PigeonOwner()
    {
        Name="白云鸽舍",
        City="广州",
        Pigeons=pigeons
    };

    ctx.Set<PigeonOwner>().Add(pigeonOwner);
    ctx.SaveChanges();

}

Console.WriteLine("保存成功!");
Console.ReadLine();